<?php
$SNAME = session_name("JANSENSESSION");
if (isset($_COOKIE[$SNAME]) || isset($_GET[$SNAME])) {
    $SID = isset($_COOKIE[$SNAME]) ? $_COOKIE[$SNAME] : $_GET[$SNAME];
    session_id($SID);
} else {
    $SID = session_id();
}

session_start();
setcookie(session_name(), session_id(), time()+3600*24*365, "/");

require_once './include/common.inc.php';
require_once './include/cart.class.php';

if (isset($_GET['act']) && $_GET['act'] == 'add' && is_numeric($_GET['pid'])) {
    $pid = $_GET['pid'];
    $name = $_GET['name'];
    $price = $_GET['price'];

    $cart = new cart();
    $cart->addOne($pid, $name, $price);
}

if (isset($_GET['act']) && $_GET['act'] == 'clearall') {
    $cart = new cart();
    $cart->emptyAll();
}

$cart = new cart();
$info_ary = $cart->getData();
$total_qty = $cart->getSortCount();
$total_cost = $cart->getTotalCost();

echo $total_qty . "<br>" . $total_cost;
echo "<hr><pre>";
print_r($info_ary);
echo "</pre><hr>";


$debug = 1;
debuginfo();
echo "<pre>";
print_r($debuginfo);

?>